const app = getApp()

Page({
  data: {
    logo: [],
    tubiao: '',
    kuanhao: '',
    yansechima: '',
    nahuojia:0 ,
    xiaoshoujia: 0,
    dabaojia: 0,
    chengbenjia: 0
  },
  //事件处理函数

  look: function () {
    console.log(this.data.logo)
  },

  saveimage: function (e) {
    console.log(e)
    var that = this
    var formData = {
    }
    wx.uploadFile({
      url: 'https://www.wenzhixinxi.com/Uploads/upload.php',
      filePath: this.data.logo[0].name,
      name: 'photo',
      success: function (res) {
        console.log(res)
        var data = res.data
        console.log(data)
        console.log(that.data.logo)
      }
    })
  },

  chooseimage: function () {
    let _this = this;
    wx.showActionSheet({
      itemList: ['从相册中选择', '拍照'],
      itemColor: "#f7982a",
      success: function (res) {
        if (!res.cancel) {
          if (res.tapIndex == 0) {
            _this.chooseWxImage('album')
          } else if (res.tapIndex == 1) {
            _this.chooseWxImage('camera')
          }
        }
      }
    })

  },
  chooseWxImage: function (type) {
    var that = this
    var tm = []
    wx.chooseImage({
      sizeType: ['original', 'compressed'],
      sourceType: [type],
      success: function (res) {
        console.log(res);
        // { { item.name } }
        that.data.logo.push({ 'name': res.tempFilePaths[0] })
        console.log('1' + that.data.logo)
        tm = that.data.logo
        console.log('2' + that.data.logo)
        console.log('3' + tm)
        that.setData({
          logo: tm
        })
      }
    })
  }
})